import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/application/special_list/violation_entity.dart';

ViolationEntity $ViolationEntityFromJson(Map<String, dynamic> json) {
  final ViolationEntity violationEntity = ViolationEntity();
  final String? companyCode = jsonConvert.convert<String>(json['companyCode']);
  if (companyCode != null) {
    violationEntity.companyCode = companyCode;
  }
  final String? createBy = jsonConvert.convert<String>(json['createBy']);
  if (createBy != null) {
    violationEntity.createBy = createBy;
  }
  final String? createDate = jsonConvert.convert<String>(json['createDate']);
  if (createDate != null) {
    violationEntity.createDate = createDate;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    violationEntity.id = id;
  }
  final String? ticketPlanId = jsonConvert.convert<String>(json['ticketPlanId']);
  if (ticketPlanId != null) {
    violationEntity.ticketPlanId = ticketPlanId;
  }
  final String? ticketReceiptId = jsonConvert.convert<String>(json['ticketReceiptId']);
  if (ticketReceiptId != null) {
    violationEntity.ticketReceiptId = ticketReceiptId;
  }
  final String? updateBy = jsonConvert.convert<String>(json['updateBy']);
  if (updateBy != null) {
    violationEntity.updateBy = updateBy;
  }
  final String? updateDate = jsonConvert.convert<String>(json['updateDate']);
  if (updateDate != null) {
    violationEntity.updateDate = updateDate;
  }
  final List<ViolationViolationListDTOList>? violationListDTOList = (json['violationListDTOList'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ViolationViolationListDTOList>(e) as ViolationViolationListDTOList).toList();
  if (violationListDTOList != null) {
    violationEntity.violationListDTOList = violationListDTOList;
  }
  final String? violationReason = jsonConvert.convert<String>(json['violationReason']);
  if (violationReason != null) {
    violationEntity.violationReason = violationReason;
  }
  final String? violationTypeId = jsonConvert.convert<String>(json['violationTypeId']);
  if (violationTypeId != null) {
    violationEntity.violationTypeId = violationTypeId;
  }
  final String? violationTypeName = jsonConvert.convert<String>(json['violationTypeName']);
  if (violationTypeName != null) {
    violationEntity.violationTypeName = violationTypeName;
  }
  return violationEntity;
}

Map<String, dynamic> $ViolationEntityToJson(ViolationEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['companyCode'] = entity.companyCode;
  data['createBy'] = entity.createBy;
  data['createDate'] = entity.createDate;
  data['id'] = entity.id;
  data['ticketPlanId'] = entity.ticketPlanId;
  data['ticketReceiptId'] = entity.ticketReceiptId;
  data['updateBy'] = entity.updateBy;
  data['updateDate'] = entity.updateDate;
  data['violationListDTOList'] = entity.violationListDTOList?.map((v) => v.toJson()).toList();
  data['violationReason'] = entity.violationReason;
  data['violationTypeId'] = entity.violationTypeId;
  data['violationTypeName'] = entity.violationTypeName;
  return data;
}

extension ViolationEntityExtension on ViolationEntity {
  ViolationEntity copyWith({
    String? companyCode,
    String? createBy,
    String? createDate,
    String? id,
    String? ticketPlanId,
    String? ticketReceiptId,
    String? updateBy,
    String? updateDate,
    List<ViolationViolationListDTOList>? violationListDTOList,
    String? violationReason,
    String? violationTypeId,
    String? violationTypeName,
  }) {
    return ViolationEntity()
      ..companyCode = companyCode ?? this.companyCode
      ..createBy = createBy ?? this.createBy
      ..createDate = createDate ?? this.createDate
      ..id = id ?? this.id
      ..ticketPlanId = ticketPlanId ?? this.ticketPlanId
      ..ticketReceiptId = ticketReceiptId ?? this.ticketReceiptId
      ..updateBy = updateBy ?? this.updateBy
      ..updateDate = updateDate ?? this.updateDate
      ..violationListDTOList = violationListDTOList ?? this.violationListDTOList
      ..violationReason = violationReason ?? this.violationReason
      ..violationTypeId = violationTypeId ?? this.violationTypeId
      ..violationTypeName = violationTypeName ?? this.violationTypeName;
  }
}

ViolationViolationListDTOList $ViolationViolationListDTOListFromJson(Map<String, dynamic> json) {
  final ViolationViolationListDTOList violationViolationListDTOList = ViolationViolationListDTOList();
  final String? violationCircle = jsonConvert.convert<String>(json['violationCircle']);
  if (violationCircle != null) {
    violationViolationListDTOList.violationCircle = violationCircle;
  }
  final List<String>? violationCircleFile = (json['violationCircleFile'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (violationCircleFile != null) {
    violationViolationListDTOList.violationCircleFile = violationCircleFile;
  }
  return violationViolationListDTOList;
}

Map<String, dynamic> $ViolationViolationListDTOListToJson(ViolationViolationListDTOList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['violationCircle'] = entity.violationCircle;
  data['violationCircleFile'] = entity.violationCircleFile;
  return data;
}

extension ViolationViolationListDTOListExtension on ViolationViolationListDTOList {
  ViolationViolationListDTOList copyWith({
    String? violationCircle,
    List<String>? violationCircleFile,
  }) {
    return ViolationViolationListDTOList()
      ..violationCircle = violationCircle ?? this.violationCircle
      ..violationCircleFile = violationCircleFile ?? this.violationCircleFile;
  }
}
